
% style stuff

\setlength{\parindent}{0in}
\setlength{\parskip}{.125in}
%\addtolength{\textwidth}{.5in}

\newlength{\maxpagewidth}
\setlength{\maxpagewidth}{\textwidth}
\addtolength{\maxpagewidth}{1in}


% editorial macros

\newlength{\notewidth}
\setlength{\notewidth}{\textwidth}
\addtolength{\notewidth}{-1.25in}

\newcommand{\remark} [1]
  {\vspace{\parskip}
   \parbox[t]{.75in}{\sc Remark:}
   \parbox[t]{\notewidth}{\em #1}
   \vspace{\parskip}
   }

\newcommand{\note}[1]
  {\vspace{\parskip}
   \parbox[t]{.75in}{\sc Note:}
   \parbox[t]{\notewidth}{\em #1}
   \vspace{\parskip}
   }

%\comment inserts comments as isolated paragraphs; end with \par

\def\comment#1\par{\medbreak \noindent [{\it #1}]\par\medbreak}

% \[ inserts comments within text; end with ]

\def\[#1]{[{\it #1}]}
\def\<#1>{$<${\it #1}$>$}

% special characters

\def\*{{\tt *}}

% Names of things

\def\t#1{{\sc T#1\/}}
\def\4th{(4\raisebox{.6ex}{\small th} edition)}

\newcommand{\keyword} [1]{\index{#1}{\sf #1}}
\newcommand{\tc}         {{\sc tc}}
\newcommand{\orbit}      {{\sc orbit}}
\newcommand{\stdcompiler}{{\sc standard-compiler}}
\newcommand{\scheme}     {{\sc scheme}}

\newcommand{\evalto}{$\Longrightarrow$\ }
\newcommand{\changedto}{$\longrightarrow$\ }
\newcommand{\parsesto}{$\longrightarrow$\ }
\renewcommand{\star}{$^*$\/}
\renewcommand{\+}{$^+$}


% Semantic domains,  used to indicate the type of a value

\newcommand{\sem}{\it}                   %semantic font
\newcommand{\semvar}[1]{{\it #1}}        %semantic font
\newcommand{\synvar}[1]{{\it $<$#1$>$}}  %syntactic font
\newcommand{\type}{\sem}
\newcommand{\zeroormore}[1]{{\sem #1$_1$ \ldots  #1$_n$}}
\newcommand{\oneormore}[1]{{\sem #1$_1$ #1$_2$ \ldots #1$_n$}}

\newcommand{\proc}        {{\sem procedure}}
\newcommand{\LAMBDA}      {\keyword{lambda}}

\newcommand{\boolean}     {{\sem boolean}}
\newcommand{\true}        {{\sem true}}
\newcommand{\false}       {{\sem false}}

\newcommand{\num}         {{\sem number}}
\newcommand{\fixnum}      {{\sem fixnum}}
\newcommand{\integer}     {{\sem integer}}

\newcommand{\character}   {{\sem character}}
\newcommand{\str}         {{\sem string}}
\newcommand{\sym}         {{\sem symbol}}

\newcommand{\location}    {{\sem location}}
\newcommand{\object}      {{\sem object}}

\newcommand{\error}       {{\sem error}}
\newcommand{\syntaxerror} {{\sem syntax error}}
\newcommand{\readerror}   {{\sem read error}}
\newcommand{\undefined}   {{\sem undefined}}


% semantic variables

\newcommand{\identifier}  {{\sem identifier}}
\newcommand{\identifiers} {\zeroormore{\<ident>}}
\newcommand{\expr}        {{\sem expression}}
\newcommand{\body}        {{\sem body}}
\newcommand{\valueofbody} {{\sem value~of~body}}
\newcommand{\emptylist}   {{\sem empty~list}}
\newcommand{\car}         {\keyword{car}}
\newcommand{\cdr}         {\keyword{cdr}}


% generally useful things

\newcommand{\indx}[1]{#1 \index{ #1 }}
\newcommand{\gloss}[1]{#1 \glossary{ #1 }}

% Definition Macros

\newlength{\definitiontypewidth}
\setlength{\definitiontypewidth}{\textwidth}
\addtolength{\definitiontypewidth}{-.7in}

\newcommand{\syntaxform}[5]
  {\index{#1}
   \vspace{\parskip}\hspace{.25in}({\bf\sf{#1}} { {\sem #2}}) \hfill #4#5\\*[.08in]
   \hspace*{.5in}\evalto\ {{\sem #3}}
   }

\newcommand{\specialform} [3]
  {\syntaxform{#1}{#2}{#3}{special form}{}}

\newcommand{\syntax} [3]
  {\syntaxform{#1}{#2}{#3}{syntax}{}}

\newcommand{\newsyntax} [3]
  {\syntaxform{#1}{#2}{#3}{syntax}{\experimental}}

\newcommand{\extdsyntax} [3]
  {\syntaxform{#1}{#2}{#3}{syntax}{\extended}}

\newcommand{\defineform}[5]
  {\index{#1}
   \vspace{\parskip}\hspace{.25in}({\bf\sf{#1}}{{\sem #2}}) \hfill #4#5\\*[.08in]
   \hspace*{.5in}\evalto\ {{\sem #3}}
   }

\newcommand{\procedure} [3]
  {\defineform{#1}{#2}{#3}{procedure}{}}

\newcommand{\newprocedure} [3]
  {\defineform{#1}{#2}{#3}{procedure}{\experimental}}

\newcommand{\addprocedure} [3]
  {\defineform{#1}{#2}{#3}{procedure}{\added}}

\newcommand{\extdprocedure} [3]
  {\defineform{#1}{#2}{#3}{procedure}{\extended}}

\newcommand{\fixedprocedure} [3]
  {\defineform{#1}{#2}{#3}{procedure}{\bugfix}}

\newcommand{\predicate} [3]
  {\defineform{#1}{#2}{#3}{predicate}{}}

\newcommand{\operation} [3]
  {\defineform{#1}{#2}{#3}{operation}{}}

\newcommand{\settable} [3]
  {\defineform{#1}{#2}{#3}{settable}{}}

% Version and feature information

\newcommand{\experimental}{\marginpar{\bf experimental}}
\newcommand{\changed}{\marginpar{\bf changed}}
\newcommand{\added}{\marginpar{\bf added}}
\newcommand{\changing}{\marginpar{\bf changing}}
\newcommand{\removed}{\marginpar{\bf removed}}
\newcommand{\extended}{\marginpar{\bf extended}}
\newcommand{\bugfix}{\marginpar{\bf fixed}}

% Code
\newcommand{\code}[1]{{\tt #1}}

\newlength{\exampleindent}
\setlength{\exampleindent}{.25in}

\newlength{\examplewidth} 
\setlength{\examplewidth}{\textwidth}
\addtolength{\examplewidth}{-\exampleindent}

                   % \begin{Example} and \Filename{}
\makeatletter      % Hacked up by -- R. James Firby --
\def\@doyoavspecials{\do\ \do\&\do\#\do\%\do\~}

\def\@formula{\trivlist \item[]\if@minipage\else\vskip\parskip\fi
\leftskip\@totalleftmargin\rightskip\z@
\parindent\z@\parfillskip\@flushglue\parskip\z@
\@tempswafalse \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par}
\obeylines \tt \let\do\@makeother \@doyoavspecials}


\def\example{\par\hspace{\exampleindent}
             \begin{minipage}{\examplewidth}
               \@formula \frenchspacing\@vobeyspaces \doexample}

\def\doexample#1{#1\end{minipage}}
             
\let\endformula=\endtrivlist

\def\@filename#1{#1\endgroup}
\def\filename{\begingroup \let\do\@makeother \@dosomespecials %
\@filename}

\makeatother


% scheme stuff

\def\r3rs{{\it Revised\/$^3$ Report on the Algorithmic Language Scheme}}
\newcommand{\values}{value(s)}
